package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceNurse;
import com.ruoyi.service.service.IServiceNurseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 院方账号表Controller
 * 
 * @author ZDL
 * @date 2024-11-19
 */
@RestController
@RequestMapping("/service/nurse")
public class ServiceNurseController extends BaseController
{
    @Autowired
    private IServiceNurseService serviceNurseService;

    /**
     * 查询院方账号表列表
     */
    @PreAuthorize("@ss.hasPermi('service:nurse:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceNurse serviceNurse)
    {
        startPage();
        List<ServiceNurse> list = serviceNurseService.selectServiceNurseList(serviceNurse);
        return getDataTable(list);
    }

    /**
     * 导出院方账号表列表
     */
    @PreAuthorize("@ss.hasPermi('service:nurse:export')")
    @Log(title = "院方账号表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceNurse serviceNurse)
    {
        List<ServiceNurse> list = serviceNurseService.selectServiceNurseList(serviceNurse);
        ExcelUtil<ServiceNurse> util = new ExcelUtil<ServiceNurse>(ServiceNurse.class);
        util.exportExcel(response, list, "院方账号表数据");
    }

    /**
     * 获取院方账号表详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:nurse:query')")
    @GetMapping(value = "/{nurseId}")
    public AjaxResult getInfo(@PathVariable("nurseId") Long nurseId)
    {
        return success(serviceNurseService.selectServiceNurseByNurseId(nurseId));
    }

    /**
     * 新增院方账号表
     */
    @PreAuthorize("@ss.hasPermi('service:nurse:add')")
    @Log(title = "院方账号表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceNurse serviceNurse)
    {
        return toAjax(serviceNurseService.insertServiceNurse(serviceNurse));
    }

    /**
     * 修改院方账号表
     */
    @PreAuthorize("@ss.hasPermi('service:nurse:edit')")
    @Log(title = "院方账号表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceNurse serviceNurse)
    {
        return toAjax(serviceNurseService.updateServiceNurse(serviceNurse));
    }

    /**
     * 删除院方账号表
     */
    @PreAuthorize("@ss.hasPermi('service:nurse:remove')")
    @Log(title = "院方账号表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{nurseIds}")
    public AjaxResult remove(@PathVariable Long[] nurseIds)
    {
        return toAjax(serviceNurseService.deleteServiceNurseByNurseIds(nurseIds));
    }
}
